{
 "metadata": {
  "signature": "sha256:3f8271dce541086cbbf0b841b2f2612eaeaf2f13eace057d9454676f3b365e27"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Function intersections\n",
      "======================================================================\n",
      "\n",
      "Find the points at which two given functions intersect\n",
      "------------------------------------------------------\n",
      "\n",
      "Consider the example of finding the intersection of a polynomial and a\n",
      "line:"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "$y_1=x_1^2$\n",
      "\n",
      "$y_2=x_2+1$"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from scipy.optimize import fsolve\n",
      "\n",
      "import numpy as np\n",
      "\n",
      "def f(xy):\n",
      "   x, y = xy\n",
      "   z = np.array([y - x**2, y - x - 1.0])\n",
      "   return z\n",
      "\n",
      "fsolve(f, [1.0, 2.0])"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 2,
       "text": [
        "array([ 1.61803399,  2.61803399])"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "See also: http://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.fsolve.html#scipy.optimize.fsolve"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}